SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO

CREATE PROCEDURE dbo.[DnnProduct_GetModulePermissionsByModuleID]
	
	@ModuleID int, 
	@PermissionID int

AS
SELECT *
FROM dbo.DnnProduct_vw_ModulePermissions
WHERE (@ModuleID = -1 
			OR ModuleID = @ModuleID
			OR (ModuleID IS NULL AND PermissionCode = 'SYSTEM_MODULE_DEFINITION')
		)
	AND	(PermissionID = @PermissionID OR @PermissionID = -1)

GO
